package com.yjd.comm.base.service.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.yjd.comm.annotation.ServiceRemoteProxy;
import com.yjd.comm.asynmsg.enums.TaskMsgClientIdEnum;
import com.yjd.comm.asynmsg.enums.TaskMsgTypeEnum;
import com.yjd.comm.asynmsg.model.TaskMsgModel;
import com.yjd.comm.asynmsg.model.TaskMsgOrderModel;
import com.yjd.comm.asynmsg.service.ITaskMsgOrderService;
import com.yjd.comm.asynmsg.service.ITaskMsgService;
import com.yjd.comm.rpm.RpmServiceKeyEnum;
import com.yjd.comm.util.FrameUtil;

/**
 * <b>description</b>：业务层基类，此类中所有方法不要加事务（AOP不会代理基类中的方法,若要加事务，请在子类中重写父类的方法） <br>
 * <b>time</b>：2014-10-13上午11:30:38 <br>
 * <b>author</b>： ready likun_557@163.com
 */
public abstract class MsgBaseServiceImpl extends TopBaseServiceImpl {

	/**
	 * logger记录系统日志
	 */
	protected Logger logger = Logger.getLogger(getClass());

	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_PUBLIC_KEY)
	private ITaskMsgService taskMsgService;
	
	@Resource
	private ITaskMsgOrderService taskMsgOrderService;
	
	/**
	* 发送消息
	* @param ref_id
	* @param msgTypeEnum
	* @param client_id
	* @return
	* @throws Exception
	 */
	public TaskMsgModel sendMsg(String ref_id, TaskMsgTypeEnum msgTypeEnum,TaskMsgClientIdEnum client_id)
			throws Exception{
		long curtime = FrameUtil.getTime(null);
		TaskMsgOrderModel taskMsgOrderModel = new TaskMsgOrderModel();
		taskMsgOrderModel.setCreate_time(curtime);
		this.taskMsgOrderService.insert(taskMsgOrderModel);
		TaskMsgModel model = this.taskMsgService.insert(ref_id, msgTypeEnum,client_id,taskMsgOrderModel.getId().toString());
		return model;
	}
}
